﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SyncService.Common
{
    public static class CommonTimeStamp
    {

        public static DateTime GetDateTimeSeconds(long timestamp)
        {
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));//当地时区  
            var time = startTime.AddMilliseconds(timestamp);
            return time;
        }
        public static DateTime StampToDateTime(string stamp)
        {
            stamp = stamp.Length >= 10 ? stamp.Substring(0, 10) : stamp;
            long timestamp = Convert.ToInt64(stamp);
            return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(timestamp).ToLocalTime();
        }
    }
}
